// 导入自己封装的已经连接的mongoose
const mongoose = require('./connect')

// 用户表的schema
const userSchema = new mongoose.Schema({
    username: {
        required: true,
        type: String
    },
    password: {
        required: true,
        type: String
    },
    email: {
        required: true,
        type: String
    },
    tel: {
        required: true,
        type: Number
    },
    enable: {
        type: Boolean,
        default: false
    },
    createdAt: {
        type: Date,
    },
    updatedAt: {
        type: Date,
    },
    role: String
})

const userModel = mongoose.model('user', userSchema, 'user')

// 导出model
module.exports = userModel